const { Blog, User } = require("./model.js");
!(async function() {
  const blogListWithUser = await Blog.findAndCountAll({
    order: [["id", "desc"]],
    include: [
      {
        model: User,
        attributes: ["userName", "nickName"],
        where: {
          userName: "zhangsan"
        }
      }
    ]
  });
  console.log(
    "blogListWithUser",
    blogListWithUser.count,
    blogListWithUser.rows.map(blog => {
      const blogVal = blog.dataValues;
      blogVal.user = blogVal.user.dataValues;
      return blogVal;
    })
  );
})();
